package com.qlk.vorder.dao.impl;

import com.qlk.common.dao.mybatis.BaseDao;
import com.qlk.vorder.dao.TaskDao;
import com.qlk.vorder.domain.Task;
import com.qlk.vorder.domain.query.TaskQuery;

import java.util.List;
import org.springframework.stereotype.Repository;

/**
 * TaskDAO实现类<br/>
 * 对'task'表进行基本的操作
 * 
 * @author zhaoyanan
 * @version 2016-7-28 14:13:59
 * 
 */
@Repository
public class TaskDaoImpl extends BaseDao implements TaskDao {
	/** namespace */
	private final String namespace = TaskDaoImpl.class.getName();

	/**
	 * {@inheritDoc}
	 */
	public List<Task> queryTaskList(TaskQuery queryBean) {
		return (List<Task>) queryForList(namespace + ".queryTaskList", queryBean);
	}

	/**
	 * {@inheritDoc}
	 */
	public boolean insert(Task task) {
		return insert(namespace + ".insert", task);
	}

	/**
	 * {@inheritDoc}
	 */
	public boolean update(Task task) {
		return update(namespace + ".update", task);
	}

	/**
	 * {@inheritDoc}
	 */
	public int queryTaskCount(TaskQuery queryBean) {
		return (Integer) queryForObject(namespace + ".queryTaskCount", queryBean);
	}

	/**
	 * {@inheritDoc}
	 */
	public List<Task> queryTaskListWithPage(TaskQuery queryBean) {
		return (List<Task>) queryForList(namespace + ".queryTaskListWithPage", queryBean);
	}

	/**
	 * {@inheritDoc}
	 */
	public boolean delete(Task configuration) {
		return delete(namespace + ".delete", configuration);
	}

	/**
	 * {@inheritDoc}
	 */
	public Task getTaskById(Long id) {
		return (Task) queryForObject(namespace + ".getTaskById", id);
	}

	/**
	 * {@inheritDoc}
	 */
	public boolean exist(Task task) {
		int count = (Integer) queryForObject(namespace + ".exist", task);
		return count > 0;
	}
}
